$.ajaxSetup({     
    contentType:"application/x-www-form-urlencoded;charset=utf-8",     
    complete:function(XMLHttpRequest,textStatus){  
    	
        var sessionStatus=XMLHttpRequest.getResponseHeader("SessionStatus");  
        if(sessionStatus=="SessionTimeout"){     
            window.location.replace("/pwtz/admin/login.jsp");     
        } 
    }  
});
$.fn.val = function(value){
	var rreturn = /\r/g;
	var hooks, ret, isFunction, elem = this[0];

	if ( !arguments.length ) {
		if ( elem ) {
			hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];

			if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
				return ret;
			}

			ret = elem.value;

			return typeof ret === "string" ?
				// handle most common string cases
				ret.replace(rreturn, "") :
				// handle cases where value is null/undef or number
				ret == null || ret == "null" ? "" : ret;
		}

		return;
	}

	isFunction = jQuery.isFunction( value );

	return this.each(function( i ) {
		var self = jQuery(this), val;

		if ( this.nodeType !== 1 ) {
			return;
		}

		if ( isFunction ) {
			val = value.call( this, i, self.val() );
		} else {
			val = value;
		}

		// Treat null/undefined as ""; convert numbers to string
		if ( val == null || val == "null") {
			val = "";
		} else if ( typeof val === "number" ) {
			val += "";
		} else if ( jQuery.isArray( val ) ) {
			val = jQuery.map(val, function ( value ) {
				return value == null ? "" : value + "";
			});
		}

		hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];

		// If set returns undefined, fall back to normal setting
		if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
			this.value = val;
		}
	});
}

function pageList(list){
	//分页
	$(".page").empty();
	var fullListSize = list.totalRecord;
 	var pageNumber = list.currPage;
 	var totalPage=list.totalPage;
 	if(fullListSize!=undefined && fullListSize!=null && fullListSize>0){
 		var start = 1;
			var end = totalPage;
			if(totalPage > 5 && pageNumber != 1) {
				if((totalPage-pageNumber)<3){
					start = pageNumber - (5 -(totalPage-pageNumber) -1);
				}else{
					start =  pageNumber -1;
				}
			} 
			if((totalPage-3)>pageNumber){
				if(pageNumber == 1) {
					end = 5;
				} else {
 				end = pageNumber + 3;
				}
			}
			var prePage = pageNumber - 1 < 1 ? 1 : pageNumber - 1;
			var nextPage = pageNumber + 1 > totalPage ? totalPage : pageNumber + 1;
			$(".page").append('<a href="javascript:goToPage(1)">首页</a> ');
			$(".page").append('<a href="javascript:goToPage('+prePage+')">上一页</a> ');
			for(var i=start;i<=end;i++){
 			if(i == pageNumber){
 				if(i < 5) {
 					$str = $('<a class="intro" href="javascript:goToPage('+i+')">'+i+'</a> ');
 				} else {
 					$str = $('<a class="intro" href="javascript:goToPage('+i+')">'+i+'</a> ');
 				}
	 		}else{
	 			if(i < 5) {
	 				$str = $('<a href="javascript:goToPage('+i+')">'+i+'</a> ');
	 			} else {
	 				$str = $('<a href="javascript:goToPage('+i+')">'+i+'</a> ');
	 			}
	 		}
				$(".page").append($str);
		}
			$(".page").append(' <a href="javascript:goToPage('+nextPage+')">下一页</a> ');
			$(".page").append('<a href="javascript:goToPage('+totalPage+')">末页</a>');
 	}
}

function pageList2(list){
	//分页
	$(".page").empty();
	var fullListSize = list.totalRecord;
 	var pageNumber = list.currPage;
 	var totalPage=list.totalPage;
 	if(fullListSize!=undefined && fullListSize!=null && fullListSize>0){
 		var start = 1;
			var end = totalPage;
			if(totalPage > 5 && pageNumber != 1) {
				if((totalPage-pageNumber)<3){
					start = pageNumber - (5 -(totalPage-pageNumber) -1);
				}else{
					start =  pageNumber -1;
				}
			} 
			if((totalPage-3)>pageNumber){
				if(pageNumber == 1) {
					end = 5;
				} else {
 				end = pageNumber + 3;
				}
			}
			var prePage = pageNumber - 1 < 1 ? 1 : pageNumber - 1;
			var nextPage = pageNumber + 1 > totalPage ? totalPage : pageNumber + 1;
			$(".page").append('<a href="javascript:goToPage2(1)">首页</a> ');
			$(".page").append('<a href="javascript:goToPage2('+prePage+')">上一页</a> ');
			for(var i=start;i<=end;i++){
 			if(i == pageNumber){
 				if(i < 5) {
 					$str = $('<a class="intro" href="javascript:goToPage2('+i+')">'+i+'</a> ');
 				} else {
 					$str = $('<a class="intro" href="javascript:goToPage2('+i+')">'+i+'</a> ');
 				}
	 		}else{
	 			if(i < 5) {
	 				$str = $('<a href="javascript:goToPage2('+i+')">'+i+'</a> ');
	 			} else {
	 				$str = $('<a href="javascript:goToPage2('+i+')">'+i+'</a> ');
	 			}
	 		}
				$(".page").append($str);
		}
			$(".page").append(' <a href="javascript:goToPage2('+nextPage+')">下一页</a> ');
			$(".page").append('<a href="javascript:goToPage2('+totalPage+')">末页</a>');
 	}
}

function pageList3(list){
	//分页
	$("#page").empty();
	var fullListSize = list.totalRecord;
 	var pageNumber = list.currPage;
 	var totalPage=list.totalPage;
 	if(fullListSize!=undefined && fullListSize!=null && fullListSize>0){
 		var start = 1;
			var end = totalPage;
			if(totalPage > 5 && pageNumber != 1) {
				if((totalPage-pageNumber)<3){
					start = pageNumber - (5 -(totalPage-pageNumber) -1);
				}else{
					start =  pageNumber -1;
				}
			} 
			if((totalPage-3)>pageNumber){
				if(pageNumber == 1) {
					end = 5;
				} else {
 				end = pageNumber + 3;
				}
			}
			var prePage = pageNumber - 1 < 1 ? 1 : pageNumber - 1;
			var nextPage = pageNumber + 1 > totalPage ? totalPage : pageNumber + 1;
			$("#page").append('<a href="javascript:toPage(1)">首页</a> ');
			$("#page").append('<a href="javascript:toPage('+prePage+')">上一页</a> ');
			for(var i=start;i<=end;i++){
 			if(i == pageNumber){
 				if(i < 5) {
 					$str = $('<a class="intro" href="javascript:toPage('+i+')">'+i+'</a> ');
 				} else {
 					$str = $('<a class="intro" href="javascript:toPage('+i+')">'+i+'</a> ');
 				}
	 		}else{
	 			if(i < 5) {
	 				$str = $('<a href="javascript:toPage('+i+')">'+i+'</a> ');
	 			} else {
	 				$str = $('<a href="javascript:toPage('+i+')">'+i+'</a> ');
	 			}
	 		}
				$("#page").append($str);
		}
			$("#page").append(' <a href="javascript:toPage('+nextPage+')">下一页</a> ');
			$("#page").append('<a href="javascript:toPage('+totalPage+')">末页</a>');
 	}
}

function alert(txt){
	var shield = document.createElement("DIV");
	shield.id = "shield";
	shield.style.position = "absolute";
	shield.style.left = "0px";
	shield.style.top = "0px";
	shield.style.width = "100%";
	shield.style.height = document.body.scrollHeight+"px";
	shield.style.background = "#333";
	shield.style.textAlign = "center";
	shield.style.zIndex = "10000";
	shield.style.filter = "alpha(opacity=30)";
	shield.style.MozOpacit=0.3;
	shield.style.opacity=0.3;
	var alertFram = document.createElement("DIV");
	alertFram.id="alertFram";
	alertFram.style.position = "fixed";
	alertFram.style.left = "55%";
	alertFram.style.top = "40%";
	alertFram.style.marginLeft = "-225px";
	alertFram.style.marginTop = "-75px";
	alertFram.style.width = "380px";
	alertFram.style.height = "200px";
	alertFram.style.background = "rgb(204, 204, 204)";
	alertFram.style.textAlign = "center";
	alertFram.style.lineHeight = "150px";
	alertFram.style.zIndex = "10001";
	strHtml = "<ul style=\"list-style:none;margin:0px;padding:0px;width:100%\">\n";
	strHtml += " <li style=\"background:#3dbfa7;text-align:left;padding-left:12px;font-size:16px;height:35px;line-height:35px;border:1px solid #F9CADE;\">[配网助手系统提示]</li>\n";
	strHtml += " <li style=\"background:#fff;text-align:center;font-size:14px;height:150px;line-height:150px;border-left:1px solid #F9CADE;border-right:1px solid #3dbfa7;\">"+txt+"</li>\n";
	strHtml += " <li style=\"background:#3dbfa7;text-align:center;font-weight:bold;height:35px;line-height:35px; border:1px solid #3dbfa7;\"><input type=\"button\" value=\"确 定\" onclick=\"doOk()\"  style=\"width:80px; height:24px; background:url(../images/add_facility.jpg) repeat-x 0 0; border:none; border-radius:5px;\" /></li>\n";
	strHtml += "</ul>\n";
	alertFram.innerHTML = strHtml;
	document.body.appendChild(alertFram);
	document.body.appendChild(shield);
	var c = 0;
	this.doAlpha = function(){
		if (c++ > 20){clearInterval(ad);return 0;}
		shield.style.filter = "alpha(opacity="+c+");";
	}
	var ad = setInterval("doAlpha()",5);
	this.doOk = function(){
		$(alertFram).remove();
		$(shield).remove();
	};
	alertFram.focus();
	document.body.onselectstart = function(){return false;};
}
/*function Confirm(txt){
	var shield = document.createElement("DIV");
	shield.id = "shield";
	shield.style.position = "absolute";
	shield.style.left = "0px";
	shield.style.top = "0px";
	shield.style.width = "100%";
	shield.style.height = document.body.scrollHeight+"px";
	shield.style.background = "#333";
	shield.style.textAlign = "center";
	shield.style.zIndex = "10000";
	shield.style.filter = "alpha(opacity=30)";
	shield.style.MozOpacit=0.3;
	shield.style.opacity=0.3;
	var alertFram = document.createElement("DIV");
	alertFram.id="alertFram";
	alertFram.style.position = "absolute";
	alertFram.style.left = "55%";
	alertFram.style.top = "40%";
	alertFram.style.marginLeft = "-225px";
	alertFram.style.marginTop = "-75px";
	alertFram.style.width = "380px";
	alertFram.style.height = "200px";
	alertFram.style.background = "rgb(204, 204, 204);";
	alertFram.style.textAlign = "center";
	alertFram.style.lineHeight = "150px";
	alertFram.style.zIndex = "10001";
	strHtml = "<ul style=\"list-style:none;margin:0px;padding:0px;width:100%\">\n";
	strHtml += " <li style=\"background:#3dbfa7;text-align:left;padding-left:12px;font-size:16px;height:35px;line-height:35px;border:1px solid #F9CADE;\">[配网助手系统提示]</li>\n";
	strHtml += " <li style=\"background:#fff;text-align:center;font-size:14px;height:150px;line-height:150px;border-left:1px solid #F9CADE;border-right:1px solid #3dbfa7;\">"+txt+"</li>\n";
	strHtml += " <li style=\"background:#3dbfa7;text-align:center;font-weight:bold;height:35px;line-height:35px; border:1px solid #3dbfa7;\"><input type=\"button\" class=\"btn_ok\" value=\"确 定\" style=\"width:80px; height:24px; background:url(../images/add_facility.jpg) repeat-x 0 0; border:none; border-radius:5px;\" /><input type=\"button\" class=\"btn_cancel\" value=\"取消\"  style=\"width:80px; height:24px; background:url(../images/add_facility.jpg) repeat-x 0 0; border:none; border-radius:5px; margin-left:15px;\" /></li>\n";
	strHtml += "</ul>\n";
	alertFram.innerHTML = strHtml;
	document.body.appendChild(alertFram);
	document.body.appendChild(shield);
	var me=this;
	$('.btn_ok').click(function(){me.doOk();});
	$('.btn_cancel').click(function(){me.doCancel();});
	var c = 0;
	this.doAlpha = function(){
		if (c++ > 20){clearInterval(ad);return 0;}
		shield.style.filter = "alpha(opacity="+c+");";
	}
	var ad = setInterval("doAlpha()",5);
	this.doOk = function(){
		$(alertFram).remove();
		$(shield).remove();
		//alertFram.focus();
		//document.body.onselectstart = function(){return false;};
		return true;
	};
	this.doCancel = function(){
		$(alertFram).remove();
		$(shield).remove();
		//alertFram.focus();
		//document.body.onselectstart = function(){return true;};
		return false;
	};
}
function confirm(txt){
	var con=new Confirm(txt);
}*/

function devicedel(device,deviceid,precode,devicetype){
	pwtzconfirm("确定要删除？",function(){
		$.ajax({
			url : contextPath+'user/'+device+'/delete',
			type : 'post',
			data : {
				deviceid : deviceid
			},
			success : function(data){
				alert(data.msgDesc);
				if(data.opResult==0)
					goToPage(1);
			}
		});
	})
}

function batchdevicedel(device){
	pwtzconfirm("确定要删除选中数据？",function(){
		var checkcount = 0;
		var secccount =0;
		  $(':checkbox:checked').each(function(){
			  checkcount++;
			  $.ajax({
				url : contextPath+'user/'+device+'/delete',
				type : 'post',
				async:false, 
				data : {
					deviceid : $(this).val()
				},
				success : function(data){
					if(data.opResult==0)
						secccount++;
				}
			  });
		  });
		  if(secccount==0){
			  alert("批量删除操作失败!");
		  }
		  else if(checkcount==secccount){
			  alert("批量删除操作成功!");
			  goToPage(1);
		  }else{
			  alert("批量删除部分操作成功!");
			  goToPage(1);
		  }
	});
}
//取消添加或编辑设备是将缓存路径下图片删除
function cleanpic(device,deviceid){
	if($('#inner_box .img_p').length>0){
		$('#inner_box .img_p').each(function(){
			//alert($(this).children(".small_pic").attr("src").substring($(this).children(".small_pic").attr("src").lastIndexOf("/")+1));
			var picname=$(this).children(".small_pic").attr("src").substring($(this).children(".small_pic").attr("src").lastIndexOf("/")+1);
			//alert($(this).children(".pid").val());
			var pid=$(this).children(".pid").val();
			if(typeof(pid)=="undefind"){
				$.ajax({
					url : contextPath+'user/picture/clean',
					type : 'post',
					data : {
						picname : picname
					},
					success : function(data){
						//alert(data.msgDesc);
					}
				});
			}
		});
		location.href=contextPath+"user/d/"+device+"list.jsp?deviceid="+deviceid;
	}else{
		location.href=contextPath+"user/d/"+device+"list.jsp?deviceid="+deviceid;
	}
}

function imgdel(dom){
	$(dom).parent().remove();
	changeimgsname();
}

function changeimgsname(){
	var imglist=$(".img_p p");
	if(imglist!=null&&imglist.length>0){
		for(var i=0;i<imglist.length;i++){
			//alert(imglist[i].innerHTML.substring(0,imglist[i].innerHTML.length-1)+(i+1));
			imglist[i].innerHTML=imglist[i].innerHTML.substring(0,imglist[i].innerHTML.length-1)+(i+1);
		}
	}
}

function decimalvalidate(data,num){
	var reg=eval('/^[0-9]{1,}+\\.[0-9]{'+num+'}$/');
	return reg.test(data);
}
/**
 * 添加*
 * @param {} data 字符串数组
 */
function addrequired(data){
	if(data instanceof Array){
		for(var i = 0; i < data.length; i++){
			var inputObj = $(":input[name="+data[i]+"]");
			if(inputObj.next("em").length == 0){
				inputObj.after("<em style='color:red'> *</em>");
			}
		}
	}
}
function autoWrite(data,selectForm){
	if(!selectForm){
		selectForm = "";
	}
	if(data instanceof Object){
		for(column in data){
			var _input = $(selectForm+" :input[name="+column+"]");
			if(_input.length > 0){
				var inputValue = data[column];
				if(typeof(inputValue) =="number" && /^\d{13,}$/.test(""+inputValue)){//date
					var _date = new Date(inputValue);
					inputValue = _date.format("yyyy-MM-dd");
				}
				_input.val(""+inputValue);
			}
		}
	}
}
Date.prototype.format = function(format){
	var o = {
		"M+" : this.getMonth()+1, //month
		"d+" : this.getDate(), //day
		"h+" : this.getHours(), //hour
		"m+" : this.getMinutes(), //minute
		"s+" : this.getSeconds(), //second
		"q+" : Math.floor((this.getMonth()+3)/3), //quarter
		"S" : this.getMilliseconds() //millisecond
	};

	if(/(y+)/.test(format)) {
		format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
	}

	for(var k in o) {
		if(new RegExp("("+ k +")").test(format)) {
			format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
		}
	}
	return format;
};
var dictionaryStart=function(dictionarytype,typeId){
	$.ajax({
		url : contextPath+"user/dictionary/list",
		data : {
			typeId : typeId
		},
		type : 'POST',
		success:function(list){
			if(null!=list && list.length>0){
				$("#"+dictionarytype).empty().show();
				var option="";
				var bl=false;
				for(var i=0;i<list.length;i++){
					if(dictionarytype=="model"){
						if(model && list[i].dictionaryValue==model){
							bl=true;
						}
					}else if(dictionarytype =="productionfactory"){
						if(productionfactory && list[i].dictionaryValue==productionfactory){
							bl=true;
						}
					}else if(dictionarytype =="towerheight"){
						if(towerheight && list[i].dictionaryValue==towerheight){
							bl=true;
						}
					}else if(dictionarytype =="wirespecification"){
						if(wirespecification && list[i].dictionaryValue==wirespecification){
							bl=true;
						}
					}else if(dictionarytype =="ratedcapacity"){
						if(ratedcapacity && list[i].dictionaryValue==ratedcapacity){
							bl=true;
						}
					}
					
					option += '<option value="'+list[i].dictionaryValue+'">'+list[i].dictionaryValue+'</option>';
				}
				if(dictionarytype=="model"){
					if(!bl && model){
						option += '<option value="'+model+'">'+model+'</option>';
					}
					$('#'+dictionarytype).append(option);
					$('#'+dictionarytype).val(model);
				}else if(dictionarytype =="productionfactory"){
					if(!bl && productionfactory){
						option += '<option value="'+productionfactory+'">'+productionfactory+'</option>';
					}
					$('#'+dictionarytype).append(option);
					$('#'+dictionarytype).val(productionfactory);
				}else if(dictionarytype =="towerheight"){
					if(!bl && towerheight){
						option += '<option value="'+towerheight+'">'+towerheight+'</option>';
					}
					$('#'+dictionarytype).append(option);
					$('#'+dictionarytype).val(towerheight);
				}else if(dictionarytype =="wirespecification"){
					if(!bl && wirespecification){
						option += '<option value="'+wirespecification+'">'+wirespecification+'</option>';
					}
					$('#'+dictionarytype).append(option);
					$('#'+dictionarytype).val(wirespecification);
				}else if(dictionarytype =="ratedcapacity"){
					if(!bl && ratedcapacity){
						option += '<option value="'+ratedcapacity+'">'+ratedcapacity+'</option>';
					}
					$('#'+dictionarytype).append(option);
					$('#'+dictionarytype).val(ratedcapacity);
				}else{
					$('#'+dictionarytype).append(option);
				}
			}
		}		
	});
};
function dictionaryadd(title,typeId,obj){
	var $li = $(obj).parent();
	var shield = document.createElement("DIV");
	shield.id = "shield";
	shield.style.position = "absolute";
	shield.style.left = "0px";
	shield.style.top = "0px";
	shield.style.width = "100%";
	shield.style.height = document.body.scrollHeight+"px";
	shield.style.background = "#333";
	shield.style.textAlign = "center";
	shield.style.zIndex = "10000";
	shield.style.filter = "alpha(opacity=30)";
	shield.style.MozOpacit=0.3;
	shield.style.opacity=0.3;
	var alertFram = document.createElement("DIV");
	alertFram.id="alertFram";
	alertFram.style.position = "fixed";
	alertFram.style.left = "55%";
	alertFram.style.top = "40%";
	alertFram.style.marginLeft = "-225px";
	alertFram.style.marginTop = "-75px";
	alertFram.style.width = "380px";
	alertFram.style.height = "200px";
	alertFram.style.background = "rgb(204, 204, 204)";
	alertFram.style.textAlign = "center";
	alertFram.style.lineHeight = "150px";
	alertFram.style.zIndex = "10001";
	strHtml = "<ul style=\"list-style:none;margin:0px;padding:0px;width:100%\">\n";
	strHtml += " <li style=\"background:#3dbfa7;text-align:left;padding-left:12px;font-size:16px;height:35px;line-height:35px;border:1px solid #F9CADE;\">[手动输入"+title+"]</li>\n";
	strHtml += " <li style=\"background:#fff;text-align:center;font-size:14px;height:150px;line-height:150px;border-left:1px solid #F9CADE;border-right:1px solid #3dbfa7;\"><span>名称：</span><input class=\"text\" type=\"text\" id=\"addcontent\"/></li>\n";
	strHtml += " <li style=\"background:#3dbfa7;text-align:center;font-weight:bold;height:35px;line-height:35px; border:1px solid #3dbfa7;\"><input type=\"button\" value=\"确 定\" onclick=\"doOk("+typeId+")\"  style=\"width:80px; height:24px; background:url("+contextPath+"user/images/add_facility.jpg) repeat-x 0 0; border:none; border-radius:5px;\" />";
	strHtml += "<input type=\"button\" value=\"取消\" onclick=\"doCancel()\"  style=\"width:80px; height:24px; margin-left:10px; background:url("+contextPath+"user/images/add_facility.jpg) repeat-x 0 0; border:none; border-radius:5px;\" /></li>\n";
	strHtml += "</ul>\n";
	alertFram.innerHTML = strHtml;
	document.body.appendChild(alertFram);
	document.body.appendChild(shield);
	var c = 0;
	this.doAlpha = function(){
		if (c++ > 20){clearInterval(ad);return 0;}
		shield.style.filter = "alpha(opacity="+c+")";
	}
	var ad = setInterval("doAlpha()",5);
	this.doOk = function(typeId){
		var dictionaryValue=$("#addcontent").val();
		if(dictionaryValue!=""&&dictionaryValue.length<12){
			$.ajax({
				url : contextPath+'user/dictionary/add',
				data : {
					dictionaryValue : dictionaryValue,
					typeId : typeId
				},
				type : 'post',
				success : function(data){
					alert(data.msgDesc);
					if(data.opResult == '0'){
						var option = '<option value="'+dictionaryValue+'">'+dictionaryValue+'</option>';
						$("select",$li).append(option);
						$(".select_down",$li).val(dictionaryValue);
					}
				}
			});
		}
		$(alertFram).remove();
		$(shield).remove();
	};
	this.doCancel=function(){
		$(alertFram).remove();
		$(shield).remove();
	};
	alertFram.focus();
	document.body.onselectstart = function(){return false;};
}

var picStart=function(typeId){
	$.ajax({
		url : contextPath+"user/dictionary/list",
		data : {
			typeId : typeId
		},
		type : 'POST',
		success:function(list){
			//alert(list.length);
			if(null!=list && list.length>0){
				$("#pictype").empty().show();
				var option="";
				for(var i=0;i<list.length;i++){
					option += '<option value="'+list[i].dictionaryValue+'">'+list[i].dictionaryValue+'</option>';
				}
				$('#pictype').append(option);
			}
		}
	});
};

function gobatchupdate(deviceType){
	if($(".checkbox:checked").length == 0){
		alert("请至少选择一条数据");
		return;
	}
	var data = "devicetype="+deviceType;
	$(".checkbox:checked").each(function(){
		data = data + "&deviceid="+$(this).val();
		data = data + "&devicename="+$(this).parent().next().text();
	});
	location.href = encodeURI(contextPath+"user/batchupdate.jsp?"+data)
}

function pwtzconfirm(msg,callback){
	var shield = document.createElement("DIV");
	shield.id = "shield";
	shield.style.position = "absolute";
	shield.style.left = "0px";
	shield.style.top = "0px";
	shield.style.width = "100%";
	shield.style.height = document.body.scrollHeight+"px";
	shield.style.background = "#333";
	shield.style.textAlign = "center";
	shield.style.zIndex = "10000";
	shield.style.filter = "alpha(opacity=30)";
	shield.style.MozOpacit=0.3;
	shield.style.opacity=0.3;
	var alertFram = document.createElement("DIV");
	alertFram.id="alertFram";
	alertFram.style.position = "fixed";
	alertFram.style.left = "55%";
	alertFram.style.top = "40%";
	alertFram.style.marginLeft = "-225px";
	alertFram.style.marginTop = "-75px";
	alertFram.style.width = "380px";
	alertFram.style.height = "200px";
	alertFram.style.background = "rgb(204, 204, 204)";
	alertFram.style.textAlign = "center";
	alertFram.style.lineHeight = "150px";
	alertFram.style.zIndex = "10001";
	strHtml = "<ul style=\"list-style:none;margin:0px;padding:0px;width:100%\">\n";
	strHtml += " <li style=\"background:#3dbfa7;text-align:left;padding-left:12px;font-size:16px;height:35px;line-height:35px;border:1px solid #F9CADE;\">配网提示</li>\n";
	strHtml += " <li style=\"background:#fff;text-align:center;font-size:14px;height:150px;line-height:150px;border-left:1px solid #F9CADE;border-right:1px solid #3dbfa7;\">"+msg+"</li>\n";
	strHtml += " <li style=\"background:#3dbfa7;text-align:center;font-weight:bold;height:35px;line-height:35px; border:1px solid #3dbfa7;\"><input type=\"button\" value=\"确 定\" onclick=\"doOk()\"  style=\"width:80px; height:24px; background:url("+contextPath+"user/images/add_facility.jpg) repeat-x 0 0; border:none; border-radius:5px;\" />";
	strHtml += "<input type=\"button\" value=\"取消\" onclick=\"doCancel()\"  style=\"width:80px; height:24px; margin-left:10px; background:url("+contextPath+"user/images/add_facility.jpg) repeat-x 0 0; border:none; border-radius:5px;\" /></li>\n";
	strHtml += "</ul>\n";
	alertFram.innerHTML = strHtml;
	document.body.appendChild(alertFram);
	document.body.appendChild(shield);
	var c = 0;
	this.doAlpha = function(){
		if (c++ > 20){clearInterval(ad);return 0;}
		shield.style.filter = "alpha(opacity="+c+")";
	}
	var ad = setInterval("doAlpha()",5);
	this.doOk = function(){
		$(alertFram).remove();
		$(shield).remove();
		callback();
	};
	this.doCancel=function(){
		$(alertFram).remove();
		$(shield).remove();
	};
	alertFram.focus();
	document.body.onselectstart = function(){return false;};
}
function val(value){
	if(value == null || value == "null"){
		return "";
	}
	return value;
}
$(function(){   
	  
	  //判断浏览器是否支持placeholder属性 
	  supportPlaceholder='placeholder'in document.createElement('input'), 
	  
	  placeholder=function(input){ 
	  
	    var text = input.attr('placeholder'), 
	    defaultValue = input.defaultValue; 
	  
	    if(!defaultValue  && text!=undefined && text!=''){ 
	    
	      //input.val(text).addClass("phcolor"); 
	    	input.wrap("<div style='float:left; margin-right:4px; position:relative;top:17px;'></div>");
	    	var label = "<label id='"+text+"' class='placeholder_desc'>"+text+"</label>";
	        input.after(label);
	    } 
	  
	    input.focus(function(){ 
	  	  
	      /*if(input.val() == text){ 
	    
	        $(this).val(""); 
	      } */
	      $("#"+text).remove();
	    }); 
	    $("#"+text).click(function(){ 

	      $("#"+text).remove();
	    }); 
	   
	    input.blur(function(){ 
	  
	      if(input.val() == "" && text!=undefined && text!=''){ 
	    	var label = "<label id='"+text+"' class='placeholder_desc'>"+text+"</label>";
	        $(this).after(label);
	      } 
	    });  
	  
	    //输入的字符不为灰色 
	    input.keydown(function(){ 
	   
	      $(this).removeClass("phcolor"); 
	    }); 
	  }; 
	  
	  //当浏览器不支持placeholder属性时，调用placeholder函数 
	  if(!supportPlaceholder){ 
	  
	    $('input').each(function(){ 
	  
	      text = $(this).attr("placeholder"); 
	  
	      if($(this).attr("type") == "text"){ 
	  
	        placeholder($(this)); 
	      } 
	    }); 
	  } 
	  
	});